Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat : pt: support property fitting #3488

Closed
wants to merge 46 commits into from

Conversation

Chengqian-Zhang
Copy link
Collaborator

Support property fitting:

One can fit multiple scalar properties at the same time (application scenario: predicting homo, lumo, bandgap of a structure at the same time), the number of properties to be fitted is determined by the "task_num" keyword in "model/fitting". Of course, it is possible to fit only 1 scalar property (same as energy).

But at the moment, it only supports averaging atomic_property to get the final property, and it doesn't add bias to each element type (different from energy), more comprehensive functions will be realized in the future pr.

You'll notice that I've also modified some parts of denoise, but due to the complexity of denoise fitting and the unfinished refactoring of the loss part @iProzd , the denoise functionality has not been fully implemented in this pr.

deepmd/pt/model/task/denoise.py Fixed Show fixed Hide fixed
deepmd/pt/model/model/denoise_model.py Fixed Show fixed Hide fixed
deepmd/pt/model/model/dp_model.py Fixed Show fixed Hide fixed
Comment on lines +69 to +71
from deepmd.pt.model.model.property_model import (
PropertyModel,
)

Check notice

Code scanning / CodeQL

Cyclic import Note

Import of module
deepmd.pt.model.model.property_model
begins an import cycle.
Comment on lines +9 to +11
from .dp_model import (
DPModel,
)

Check notice

Code scanning / CodeQL

Cyclic import Note

Import of module
deepmd.pt.model.model.dp_model
begins an import cycle.
Comment on lines +64 to +74
def eval(
self,
coords: np.ndarray,
cells: Optional[np.ndarray],
atom_types: Union[List[int], np.ndarray],
atomic: bool = False,
fparam: Optional[np.ndarray] = None,
aparam: Optional[np.ndarray] = None,
mixed_type: bool = False,
**kwargs: Dict[str, Any],
) -> Tuple[np.ndarray, ...]:

Check notice

Code scanning / CodeQL

Returning tuples with varying lengths Note

DeepProperty.eval returns
tuple of size 1
and
tuple of size 2
.
deepmd/pt/model/task/denoise.py Fixed Show fixed Hide fixed
Copy link

codecov bot commented Mar 18, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 47 lines in your changes missing coverage. Please review.

Project coverage is 77.66%. Comparing base (dc14719) to head (34ea4d8).
Report is 448 commits behind head on devel.

Files with missing lines Patch % Lines
deepmd/pt/loss/property.py 27.08% 35 Missing ⚠️
deepmd/pt/train/training.py 0.00% 4 Missing ⚠️
deepmd/dpmodel/fitting/property_fitting.py 92.85% 2 Missing ⚠️
deepmd/infer/deep_property.py 90.90% 2 Missing ⚠️
deepmd/pt/infer/deep_eval.py 33.33% 2 Missing ⚠️
deepmd/pt/model/model/dp_model.py 75.00% 1 Missing ⚠️
deepmd/pt/model/task/property.py 96.96% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #3488      +/-   ##
==========================================
- Coverage   77.68%   77.66%   -0.02%     
==========================================
  Files         432      437       +5     
  Lines       37335    37523     +188     
  Branches     1620     1620              
==========================================
+ Hits        29002    29143     +141     
- Misses       7472     7519      +47     
  Partials      861      861              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@Chengqian-Zhang Chengqian-Zhang marked this pull request as draft March 19, 2024 04:08
@Chengqian-Zhang Chengqian-Zhang marked this pull request as ready for review March 19, 2024 04:09
@iProzd iProzd requested review from iProzd and wanghan-iapcm March 19, 2024 05:50
@wanghan-iapcm wanghan-iapcm changed the title pt Feat : support property fitting in deepmd-kit v3 Feat : pt: support property fitting Mar 19, 2024
Copy link
Collaborator

@wanghan-iapcm wanghan-iapcm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is highly recommended to only provide property fitting imple. in this PR and provide all denoise supports in a separate PR.

deepmd/utils/argcheck.py Outdated Show resolved Hide resolved
deepmd/utils/argcheck.py Outdated Show resolved Hide resolved
@Chengqian-Zhang
Copy link
Collaborator Author

@wanghan-iapcm Seemly I do not have the necessary permissions to add reviewers to a pull request in the repository. Can you give me higher access?
Rjiexf3OdW

deepmd/infer/deep_property.py Outdated Show resolved Hide resolved
deepmd/infer/deep_property.py Outdated Show resolved Hide resolved
deepmd/pt/loss/property.py Outdated Show resolved Hide resolved
deepmd/pt/model/model/property_model.py Outdated Show resolved Hide resolved
@Chengqian-Zhang Chengqian-Zhang requested a review from njzjz March 19, 2024 14:14
deepmd/utils/argcheck.py Outdated Show resolved Hide resolved
deepmd/dpmodel/fitting/property_fitting.py Outdated Show resolved Hide resolved
deepmd/pt/loss/property.py Show resolved Hide resolved
examples/property/train/input_torch.json Outdated Show resolved Hide resolved
deepmd/utils/argcheck.py Outdated Show resolved Hide resolved
@Chengqian-Zhang
Copy link
Collaborator Author

I think dptest also needs to be implemented in this PR?

@wanghan-iapcm
Copy link
Collaborator

the output stat should be replace by the change_out_bias method provided in #3480

@wanghan-iapcm
Copy link
Collaborator

#3480 is merging @Chengqian-Zhang please update the pr accordingly.

@Chengqian-Zhang
Copy link
Collaborator Author

@wanghan-iapcm Copy that, I will update immediately.

@Chengqian-Zhang
Copy link
Collaborator Author

I will complete this function in another PR #3867

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants